import QtQuick 2.0
import QtQuick.Controls 2.2

import "../../common"
import "../../../js/util.js" as Util
import "../../../js/UI.js" as Style

Page {
    id: m_mycurriclum

    ATitle{
        id: m_title
        anchors.top: parent.top
        anchors.left: parent.left
        m_text: "已选课程"
        m_textcol: Style.fonttilteColor
        onBackSignal: subpageSignal(1,-1)
    }

    Rectangle{
        width: parent.width
        height: childrenRect.height
        anchors.top: m_title.bottom
        anchors.topMargin: 10
        color: "transparent"
        ListView{
            id: listview
            width: parent.width
            height: childrenRect.height
            anchors.top: parent.top
            anchors.topMargin: m_lineValue*0.2
            clip: true
            model: m_list
            spacing:10
            delegate: Curriculumdelegate{
                m_source: model.source
                m_name: model.name
                m_university: model.university
                m_week: model.week
                m_numbers: model.numbers
                onClickedsignal: {
                    Util.pushView(component,m_objects,"qrc:/qml/form/curriculum/Selectcurriculum.qml",m_root_id,{"currentId":model.cur_id})
                }
            }
        }
    }

    ListModel{
        id: m_list
    }
    Component.onCompleted: {
        m_list.clear()
        for(var i=0;i<DatabaseEngine.mycurriculum.length;i++){
            m_list.append({"source":("qrc:/image/curriculum/%1.jpg").arg(DatabaseEngine.mycurriculum[i].cur_id),
                              "name":DatabaseEngine.mycurriculum[i].cur_name,
                              "university": DatabaseEngine.mycurriculum[i].cur_school,
                              "week": DatabaseEngine.mycurriculum[i].cur_time,
                              "numbers": DatabaseEngine.mycurriculum[i].cur_numbers,
                              "cur_id":DatabaseEngine.mycurriculum[i].cur_id
                          })
        }
    }
}
